package com.dg.cuckoo.admin.service.impl;

import com.dg.cuckoo.admin.dto.proCarryOut.ProExpendDto;
import com.dg.cuckoo.admin.repository.ProExpendRepository;
import com.dg.cuckoo.admin.service.ProscheduleService;
import com.dg.cuckoo.admin.vo.ProscheduleVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class ProscheduleServiceimpl implements ProscheduleService {

    @Autowired
    private ProExpendRepository proExpendRepository;

    @Override
    public List<ProscheduleVo> select(String id) {
        List<ProExpendDto> dtos = proExpendRepository.findByProjectId(id);
        List<ProscheduleVo> vos=new ArrayList<>();
        for (ProExpendDto p:dtos){
            ProscheduleVo vo = new ProscheduleVo();
            vo.setTime(p.getData());
            vo.setType(p.getType());
            vo.setProjectName(p.getContract());
            vo.setAmount(p.getAmount());
            vo.setWhether(0);
            if(p.getType()!=9){
                vo.setWhether(1);
            }
            vos.add(vo);
        }
        return vos;
    }
}
